// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_BPT_APPLICATION_ITEM
// * CreateDate    : 2011/8/16 10:16:40
// * Creater       : CodeSmith
// * LastChangeDate: 2011/8/16 10:16:40
// * LastChanger   : 2011/8/16 10:16:40
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Bpt
{
/// <summary>
    /// BptApplicationItem
    /// </summary>
    public partial class BptApplicationItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objBptApplicationItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static BptApplicationItemEntity GetBptApplicationItem(BptApplicationItemEntity objBptApplicationItemEntity)
        {
            return DataAccess.SelectSingle<BptApplicationItemEntity>(objBptApplicationItemEntity);
        }
        public static BptApplicationItemEntity GetbptApplicationItemByID(string itemID)
        {
            if (string.IsNullOrEmpty(itemID))
            {
                return null;
            }
            BptApplicationItemEntity entity = new BptApplicationItemEntity();
            entity.ApplicationItemId = itemID;
            return DataAccess.SelectSingle<BptApplicationItemEntity>(entity);
        }
        public static DataTable GetApplicationItemByID(string ApplicationID)
        {
            string sql = "select A.*,B.APPLICATION_CODE,D.PRODUCT_CODE ,E.QTY,E.BLUEPRINT_START_DATE  from dbo.BPT_APPLICATION_ITEM A left join dbo.BPT_APPLICATION B ON A.APPLICATION_ID=B.APPLICATION_ID left join dbo.MST_PRODUCT D on A.PRODUCT_ID=D.PRODUCT_ID left join dbo.SALES_PROD_PLAN_APPLICATION_ITEM E on A.PLAN_APPLICATION_ITEM_ID=E.APPLICATION_ITEM_ID where A.APPLICATION_ID = '" + ApplicationID + "'";
            DataSet ds = new DataSet();
            ds = DataAccess.SelectDataSet(sql);
            if (ds != null && ds.Tables.Count > 0)
            {
                return ds.Tables[0];
            }
            return null;
            
        }

        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objBptApplicationItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertBptApplicationItem(BptApplicationItemEntity objBptApplicationItemEntity)
        {
            return DataAccess.Insert(objBptApplicationItemEntity);
        }

        public static bool InsertBptApplicationItem(List<BptApplicationItemEntity> objBptApplicationItemEntityList)
        {
            return DataAccess.Insert(objBptApplicationItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objBptApplicationItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateBptApplicationItem(BptApplicationItemEntity objBptApplicationItemEntity)
        {
            return DataAccess.Update(objBptApplicationItemEntity);
        }

        public static bool UpdateBptApplicationItem(List<BptApplicationItemEntity> objBptApplicationItemEntityList)
        {
            return DataAccess.Update<BptApplicationItemEntity>(objBptApplicationItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objBptApplicationItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteBptApplicationItem(BptApplicationItemEntity objBptApplicationItemEntity)
        {
            return DataAccess.Delete(objBptApplicationItemEntity);
        }

        public static bool DeleteBptApplicationItem(List<BptApplicationItemEntity> objBptApplicationItemEntityList)
        {
            return DataAccess.Delete<BptApplicationItemEntity>(objBptApplicationItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetBptApplicationItemAll()
        {
            return DataAccess.SelectAllDataSet<BptApplicationItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<BptApplicationItemEntity> GetBptApplicationItemAllList()
        {
            return DataAccess.SelectAll<BptApplicationItemEntity>();
        }
        #endregion
	}
	
	
}	

